package com.danceforyou.common.restful.exception;

import java.io.PrintWriter;
import java.io.StringWriter;

public class BizException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	private String code;
    private String msg;
    private String debugMsg;

    public BizException(String msg) {
        this.code = "9999999";
        this.msg = msg;
    }

    public BizException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BizException(String errorCode, String msg, String debugMsg) {
        this(errorCode, msg);
        this.debugMsg = debugMsg;
    }

    public BizException(String errorCode, String msg, Throwable cause) {
        this(errorCode, msg);
        StringWriter writer = new StringWriter();
        cause.printStackTrace(new PrintWriter(writer, true));
        this.debugMsg = writer.toString();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getDebugMsg() {
        return debugMsg;
    }

    public void setDebugMsg(String debugMsg) {
        this.debugMsg = debugMsg;
    }

    @Override
    public String toString() {
        return "BizException{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", debugMsg='" + debugMsg + '\'' +
                '}';
    }
}
